const express = require('express');
const regionModel = require('../model/region')
const router = express.Router();

// 添加类型
router.post('/add',async (req,res)=>{
   const {name} = req.body;
   
   const resData = await regionModel.create({
            cname:name
       })
    if(resData) {
        res.send({
            msg:'添加成功',
            code:1
        })
    } else {
        res.send({
            msg:'添加失败',
            code:0
        })
    }
   
})
// /region/all
router.get('/all',async (req,res)=>{
    let resData = await regionModel.find();
    res.send({
        msg:'请求成功',
        data:resData,
        code:1
    })
})

module.exports = router;